﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>


    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset" style="display:none">
                <legend>一车间大报表</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="" lay-filter="example">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">开始日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="BeginDate" autocomplete="off" class="layui-input" name="BeginDate" readonly="readonly">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">结束日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="EndDate" autocomplete="off" class="layui-input" name="EndDate" readonly="readonly">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">操作员</label>
                                <div class="layui-input-inline">
                                    <select name="UserID" lay-search id="UserID">
                                        <option value="0">全部</option>
                                        @Html.Raw(ViewBag.Users)
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                </div>
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
            </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script src="~/layuimini/js/lay-config.js"></script>
    <script>
        layui.config({
            base: '/layui/extend/'
        }).extend({
            soulTable: 'soulTable'
        }).use(['form', 'table', 'laydate', 'soulTable'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                soulTable = layui.soulTable;

            laydate.render({
                elem: '#BeginDate'
                , format: 'yyyy-MM-dd'
                , type: 'date'
                , trigger: 'click'
                , value: '@DateTime.Now.AddMonths(0).ToString("yyyy-MM-01")'
            });
            laydate.render({
                elem: '#EndDate'
                , format: 'yyyy-MM-dd'
                 , type: 'date'
               , trigger: 'click'
                 , value: '@DateTime.Now.AddMonths(0).ToString("yyyy-MM-dd")'
            });

        table.render({
            elem: '#table',
            method: 'post',
            url: '@Url.Action("ReportForBill1Async", "Bill1")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               , limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            //where: {
            //    UserID: form.val('example').UserID,
            //    BeginDate: form.val('example').BeginDate,
            //    EndDate: form.val('example').EndDate,
            //},
            cellMinWidth:120,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', { layEvent: 'export', icon: 'layui-icon-export', title: '导出' }, 'print'],
            cols: [[
                { type: 'numbers', title: '序号', width: 50},
                { field: 'ID', title: 'ID', width: 100, hide: true},
                { field: 'Code', title: '流程卡号'},
                { field: 'TouDate', title: '投产日期' },
                { field: 'LingDate', title: '领料月份' },
                { field: 'QianJiaoDate', title: '前端完工月份' },
                { field: 'HouJiaoDate', title: '最终完工月份' },
                { field: 'Model', title: '投产型号' },
                { field: 'Model', title: '成品型号' },
                { field: 'BigClassName', title: '产品大类类别' },
                { field: 'SGoodsName', title: '硅片名称' },
                { field: 'TouQty', title: '投片数' },
                { field: 'QianJiaoQty', title: '传片数' },
                { field: 'StateName', title: '晶圆状态' },
                { field: 'XinPianMianJi', title: '芯片面积' },

                { field: 'Row1Name', title: '工序1' },
                { field: 'Row1Qty',  title: '传片1' },

                { field: 'Row2Name', title: '工序2' },
                { field: 'Row2Qty',  title: '传片2' },

                { field: 'Row3Name', title: '工序3' },
                { field: 'Row3Qty',  title: '传片3' },

                { field: 'Row4Name', title: '工序4' },
                { field: 'Row4Qty',  title: '传片4' },

                { field: 'Row5Name', title: '工序5' },
                { field: 'Row5Qty',  title: '传片5' },

                { field: 'Row6Name', title: '工序6' },
                { field: 'Row6Qty',  title: '传片6' },

                { field: 'Row7Name', title: '工序7' },
                { field: 'Row7Qty',  title: '传片7' },

                { field: 'Row8Name', title: '工序8' },
                { field: 'Row8Qty',  title: '传片8' },

                { field: 'Row9Name', title: '工序9' },
                { field: 'Row9Qty',  title: '传片9' },

                { field: 'Row10Name', title: '工序10' },
                { field: 'Row10Qty',  title: '传片10' },

                { field: 'Row11Name', title: '工序11' },
                { field: 'Row11Qty',  title: '传片11' },

                { field: 'Row12Name', title: '工序12' },
                { field: 'Row12Qty',  title: '传片12' },

                { field: 'Row13Name', title: '工序13' },
                { field: 'Row13Qty',  title: '传片13' },

                { field: 'Row14Name', title: '工序14' },
                { field: 'Row14Qty',  title: '传片14' },

                { field: 'Row15Name', title: '工序15' },
                { field: 'Row15Qty',  title: '传片15' },

                { field: 'Row16Name', title: '工序16' },
                { field: 'Row16Qty',  title: '传片16' },

                { field: 'Row17Name', title: '工序17' },
                { field: 'Row17Qty',  title: '传片17' },

                { field: 'Row18Name', title: '工序18' },
                { field: 'Row18Qty',  title: '传片18' },

                { field: 'Row19Name', title: '工序19' },
                { field: 'Row19Qty',  title: '传片19' },

                { field: 'Row20Name', title: '工序20' },
                { field: 'Row20Qty',  title: '传片20' },

                { field: 'Row21Name', title: '工序21' },
                { field: 'Row21Qty',  title: '传片21' },

                { field: 'Row22Name', title: '工序22' },
                { field: 'Row22Qty',  title: '传片22' },

                { field: 'Row23Name', title: '工序23' },
                { field: 'Row23Qty',  title: '传片23' },

                { field: 'Row24Name', title: '工序24' },
                { field: 'Row24Qty',  title: '传片24' },

                { field: 'Row25Name', title: '工序25' },
                { field: 'Row25Qty',  title: '传片25' },

                { field: 'Row26Name', title: '工序26' },
                { field: 'Row26Qty',  title: '传片26' },

                { field: 'Row27Name', title: '工序27' },
                { field: 'Row27Qty',  title: '传片27' },

                { field: 'Row28Name', title: '工序28' },
                { field: 'Row28Qty',  title: '传片28' },

                { field: 'Row29Name', title: '工序29' },
                { field: 'Row29Qty',  title: '传片29' },

                { field: 'Row30Name', title: '工序30' },
                { field: 'Row30Qty',  title: '传片30' },

                { field: 'Row31Name', title: '工序31' },
                { field: 'Row31Qty',  title: '传片31' },

                { field: 'Row32Name', title: '工序32' },
                { field: 'Row32Qty',  title: '传片32' },

                { field: 'Row33Name', title: '工序33' },
                { field: 'Row33Qty',  title: '传片33' },

                { field: 'Row34Name', title: '工序34' },
                { field: 'Row34Qty',  title: '传片34' },

                { field: 'Row35Name', title: '工序35' },
                { field: 'Row35Qty',  title: '传片35' },

                { field: 'Row36Name', title: '工序36' },
                { field: 'Row36Qty',  title: '传片36' },

                { field: 'Row37Name', title: '工序37' },
                { field: 'Row37Qty',  title: '传片37' },

                { field: 'Row38Name', title: '工序38' },
                { field: 'Row38Qty',  title: '传片38' },

                { field: 'Row39Name', title: '工序39' },
                { field: 'Row39Qty',  title: '传片39' },

                { field: 'Row40Name', title: '工序40' },
                { field: 'Row40Qty',  title: '传片40' },

                { field: 'Row41Name', title: '工序41' },
                { field: 'Row41Qty',  title: '传片41' },

                { field: 'Row42Name', title: '工序42' },
                { field: 'Row42Qty',  title: '传片42' },

                { field: 'Row43Name', title: '工序43' },
                { field: 'Row43Qty',  title: '传片43' },

                { field: 'Row44Name', title: '工序44' },
                { field: 'Row44Qty',  title: '传片44' },

                { field: 'Row45Name', title: '工序45' },
                { field: 'Row45Qty',  title: '传片45' },

                { field: 'Row46Name', title: '工序46' },
                { field: 'Row46Qty',  title: '传片46' },

                { field: 'Row47Name', title: '工序47' },
                { field: 'Row47Qty',  title: '传片47' },

                { field: 'Row48Name', title: '工序48' },
                { field: 'Row48Qty',  title: '传片48' },

                { field: 'Row49Name', title: '工序49' },
                { field: 'Row49Qty',  title: '传片49' },

                { field: 'Row50Name', title: '工序50' },
                { field: 'Row50Qty',  title: '传片50' },

                @(Html.Raw(ViewBag.aaa))
                @(Html.Raw(ViewBag.bbb))

                { field: 'SheQty', title: '单大片可划量' },
                { field: 'TotalSheQty', title: '可划总量' },
                { field: 'HouJiaoQty', title: '成品晶粒量' },
                { field: 'HouFailQty', title: '废品晶粒数' },
                { field: 'HouTouQty', title: '实际划片数' },
                { field: 'HouStateName', title: '实际划片芯片状态' },
                { field: 'NoTouQty', title: '剩余晶圆片数' },
                { field: 'HouTaskTimeOne', title: '划片阶段工时/片' },
                { field: 'HouTaskTime', title: '后端划片阶段工时' },
                { field: 'TaskTime', title: '前端工时' },
                { field: 'FailQty', title: '废品数' },
                { field: 'DaiJianQty', title: '代捡晶粒' },
                { field: 'InStockQty', title: '入库数量' },
                { field: 'SaleQty', title: '销售数量' },
                { field: 'YanZhengFailQty', title: '验证废品数' },
            ]
            ],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: true,
            //skin: 'line',
            //totalRow: true,
            height: 'full-50',
            size:'sm',
            excel: { filename: '导出.xlsx' }
            , done: function () {
                soulTable.render(this)
            }
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill3")',
                    end: function () {
                        RefreshTable();

                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('table')
                    , data = checkStatus.data;
                if (data.length == 0) {
                    layer.msg('请选择您要删除的数据！', { icon: 5, time: 2000 });
                    return;
                }

                var arr = [];
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i].ID);
                }

                var ids = arr.join(",");


                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("IndexDelAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { IDs: ids },
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.Type;
                            if (type == 1) {
                                layer.msg(data.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(data.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'export') {  // 监听删除操作
                soulTable.export('table', {
                    filename: '一车间.xlsx'
                });
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '修改流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill3")' + '?ID=' + data.ID,
                    end: function () {
                        RefreshTable();
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID ,State:3},
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'details') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("DetailsList", "Bill3")' + '?ID=' + data.ID,
                    title: "流程卡详情",
                });
                return false;
            } else if (obj.event === 'jiaofu') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("JiaoFuList", "Bill3")' + '?ID=' + data.ID,
                    title: "流程卡交付详情",
                });
                return false;
            } else if (obj.event === 'touchan') {
                layer.confirm('投产后不能修改流卡信息，是否继续？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID,State:1 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'wancheng') {
                layer.confirm('确认此流程卡工序全部完成？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID, State: 2 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            }
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    UserID: form.val('example').UserID,
                    BeginDate: form.val('example').BeginDate,
                    EndDate: form.val('example').EndDate,

                }
            }, 'data');

        }

    });
    </script>
</body>
</html>